Skip to content

CM-1038: Replace istiocsr type-specific decoders with generic DecodeObjBytes - #418

Merged
openshift-merge-bot[bot] merged 2 commits into
openshift:masterfrom
sebrandon1:replace-decoders-with-generic
Oct 29, 2026
Merged

openshift-merge-bot[bot] merged 2 commits into
openshift:masterfrom
sebrandon1:replace-decoders-with-generic

Conversation

@sebrandon1

@sebrandon1 sebrandon1 commented May 6, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Remove 8 type-specific decode*ObjBytes functions from the istiocsr package (~95 lines) and replace all 22 call sites with the existing generic common.DecodeObjBytes[T] helper, reducing net code by 35 lines
  • Decode the istio-csr ServiceAccount name inline in rbacs.go with the generic helper (per review, no package-level cache)
  • Aligns the istiocsr package with the pattern established by the trustmanager package in CM-867: Implement trust-manager resource reconcilers #379
  • Add direct unit tests for DecodeObjBytes covering successful decode, panic on invalid bytes, and panic on type mismatch
  • Add test coverage for EffectiveSpec nil-Custom error path (pkg/tlsprofile)

Jira

  • CM-1038 -- Replace istiocsr type-specific decoders with generic DecodeObjBytes (Code Review)

Test Plan

  • Unit tests pass (go test ./pkg/controller/istiocsr/...)
  • New DecodeObjBytes unit tests pass (go test ./pkg/controller/common/...)
  • New EffectiveSpec nil-Custom test passes (go test ./pkg/tlsprofile/...)
  • Build succeeds (go build ./pkg/controller/istiocsr/)
  • No new lint issues introduced
  • CI checks pass

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 6, 2026
@openshift-ci-robot

openshift-ci-robot commented May 6, 2026 •

Copy link
Copy Markdown

@sebrandon1: This pull request references CM-1038 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Remove 8 type-specific decode*ObjBytes functions from the istiocsr package (~95 lines) and replace all 22 call sites with the existing generic common.DecodeObjBytes[T] helper
  • Cache the ServiceAccount name at init time to avoid redundant YAML deserialization on every reconcile cycle
  • Aligns the istiocsr package with the pattern already used by the trustmanager package

Test plan

  • Unit tests pass (go test ./pkg/controller/istiocsr/...)
  • Build succeeds (go build ./pkg/controller/istiocsr/)
  • No new lint issues introduced
  • CI checks pass

Jira: https://redhat.atlassian.net/browse/CM-1038

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Replaces bespoke embedded-manifest decode helpers with common.DecodeObjBytes[T] across IstioCSR runtime and test builders, caches the ServiceAccount name during package initialization, and removes the old decode helper functions.

Changes

IstioCSR Decoding Consolidation

Layer / File(s) Summary
Caching foundation and helper removal
pkg/controller/istiocsr/utils.go
Adds assets import and cachedServiceAccountName; initializes it in init() from the embedded ServiceAccount asset; removes the local decode*ObjBytes helpers.
Runtime object decoders
pkg/controller/istiocsr/certificates.go, pkg/controller/istiocsr/deployments.go, pkg/controller/istiocsr/serviceaccounts.go, pkg/controller/istiocsr/services.go
Certificate, Deployment, ServiceAccount, and Service builders now decode embedded assets with common.DecodeObjBytes[T] using the matching scheme group/version.
RBAC decoding and cached SA use
pkg/controller/istiocsr/rbacs.go
RBAC reconciliation reads cachedServiceAccountName, and ClusterRole, ClusterRoleBinding, Role, and lease-related RBAC builders decode via common.DecodeObjBytes[T].
Test helper decoder updates
pkg/controller/istiocsr/test_utils.go
Test builders for Certificate, RBAC, Deployment, Service, and ServiceAccount switch to common.DecodeObjBytes[T] and add the shared common import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks: Passed 14
Check name Status Explanation
Title check Passed The title accurately summarizes the main change: replacing istiocsr-specific decoders with the generic DecodeObjBytes helper.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names Passed PASS: No Ginkgo titles exist in pkg/controller/istiocsr tests, and no computed subtest names were found; existing names are static string literals.
Test Structure And Quality Passed No Ginkgo specs were added or changed in the touched package; tests are table-driven testing.T fakes with no cluster waits or cleanup issues.
Microshift Test Compatibility Passed The PR only refactors istiocsr unit-test helpers and controller code; no new Ginkgo e2e specs or MicroShift-unsupported APIs/features were added.
Single Node Openshift (Sno) Test Compatibility Passed No new Ginkgo/e2e specs were added; the PR only changes controller code and standard Go unit-test helpers, with no multi-node assumptions or SNO skips needed.
Topology-Aware Scheduling Compatibility Passed Only object-decoding helpers changed; deployment/affinity/nodeSelector/replica logic and embedded manifests are unchanged, so no topology-sensitive scheduling was introduced.
Ote Binary Stdout Contract Passed No stdout writes were added in init/setup code; the new init() only caches the ServiceAccount name via DecodeObjBytes, and searches found no fmt/log/klog stdout use in touched files.
Ipv6 And Disconnected Network Test Compatibility Passed PASS: The PR only changes unit-test helpers and standard t.Run tests; no new Ginkgo/e2e tests, IPv4-only parsing, or external/public connectivity were added.
No-Weak-Crypto Passed Touched files contain no weak-crypto APIs or secret comparisons; only standard x509/rand/rsa usage appears in tests and cert handling.
Container-Privileges Passed Changed files only swap decoders; no privileged fields are added. The istio-csr deployment manifest uses allowPrivilegeEscalation:false, runAsNonRoot:true, and drops ALL caps.
No-Sensitive-Data-In-Logs Passed PASS: The PR only swaps decoders/caches a SA name; touched log calls emit generic resource/namespace identifiers and no secrets, tokens, PII, or hostnames.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from bharath-b-rh and mytreya-rh May 6, 2026 16:16
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from b622911 to ee01305 Compare May 14, 2026 19:07
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from ee01305 to b251d62 Compare May 29, 2026 15:51
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from b251d62 to 0132362 Compare June 15, 2026 16:25
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from 0132362 to de5454a Compare June 24, 2026 19:51
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from de5454a to 767d653 Compare July 6, 2026 16:17
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch 2 times, most recently from 1d5151a to 29cd1ce Compare July 17, 2026 18:54
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch 2 times, most recently from 32e004f to f61b523 Compare August 4, 2026 18:07
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

2 similar comments
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from f61b523 to 5a2c94a Compare August 21, 2026 14:30
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from 5a2c94a to b886957 Compare August 31, 2026 15:25
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from b886957 to 709f7e9 Compare September 9, 2026 15:12
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from 709f7e9 to f9b46ea Compare September 21, 2026 18:36
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from f9b46ea to 70f4c54 Compare October 5, 2026 16:08
@sebrandon1

Copy link
Copy Markdown
Member Author

/retest

@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from 70f4c54 to dfee2c3 Compare October 23, 2026 16:49
Comment thread pkg/controller/istiocsr/rbacs.go Outdated
@openshift-ci-robot

openshift-ci-robot commented Oct 27, 2026 •

Copy link
Copy Markdown

@sebrandon1: This pull request references CM-1038 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.1.0" version, but no target version was set.

Details

In response to this:

Summary

  • Remove 8 type-specific decode*ObjBytes functions from the istiocsr package (~95 lines) and replace all 22 call sites with the existing generic common.DecodeObjBytes[T] helper, reducing net code by 35 lines
  • Decode the istio-csr ServiceAccount name inline in rbacs.go with the generic helper (per review, no package-level cache)
  • Aligns the istiocsr package with the pattern established by the trustmanager package in CM-867: Implement trust-manager resource reconcilers #379
  • Add direct unit tests for DecodeObjBytes covering successful decode, panic on invalid bytes, and panic on type mismatch
  • Add test coverage for EffectiveSpec nil-Custom error path (pkg/tlsprofile)

Jira

  • CM-1038 -- Replace istiocsr type-specific decoders with generic DecodeObjBytes (Code Review)

Test Plan

  • Unit tests pass (go test ./pkg/controller/istiocsr/...)
  • New DecodeObjBytes unit tests pass (go test ./pkg/controller/common/...)
  • New EffectiveSpec nil-Custom test passes (go test ./pkg/tlsprofile/...)
  • Build succeeds (go build ./pkg/controller/istiocsr/)
  • No new lint issues introduced
  • CI checks pass

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@bharath-b-rh

Copy link
Copy Markdown
Contributor

/lgtm
/approve
/label docs-approved
/label px-approved
/label qe-approved

/retest

@openshift-ci openshift-ci Bot added docs-approved Signifies that Docs has signed off on this PR px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR labels Oct 28, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Oct 28, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-operator-coverage

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 28, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 66339b0 and 2 for PR HEAD b9e327c in total

@sebrandon1

Copy link
Copy Markdown
Member Author

/retest-required

…bjBytes

Replace 8 type-specific decode functions in istiocsr/utils.go with a
single generic DecodeObjBytes[T] in common/utils.go.

Add direct unit tests for DecodeObjBytes covering successful decode,
panic on invalid bytes, and panic on type mismatch. Add test for
EffectiveSpec nil Custom field error path.
@sebrandon1
sebrandon1 force-pushed the replace-decoders-with-generic branch from b9e327c to 6b56b32 Compare October 28, 2026 15:29
@sebrandon1

Copy link
Copy Markdown
Member Author

Rebased onto master (6b56b32) to resolve a merge conflict with #461.

#461 added a table-driven TestDecodeObjBytes to pkg/controller/common/utils_test.go that covers the same success and invalid-bytes paths as this PR's standalone TestDecodeObjBytes_Success and TestDecodeObjBytes_PanicsOnInvalidBytes. Rather than keep duplicates, I kept master's table and added this PR's only new case ("type mismatch panics": a ServiceAccount manifest decoded as a ConfigMap) to it. The standalone tests and the testCodecFactory helper are dropped. The production changes (generic decoder in istiocsr, inline service account name decode) are unchanged.

go vet ./..., the controller and tlsprofile unit tests (811) and make lint (no new issues vs master) pass locally. CI is re-running.

@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 28, 2026
@bharath-b-rh

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Oct 29, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-operator-coverage

@openshift-ci

openshift-ci Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: anandkuma77, bharath-b-rh, sebrandon1

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci

openshift-ci Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@sebrandon1: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.17391% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.75%. Comparing base (b7149a8) to head (6b56b32).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
pkg/controller/istiocsr/test_utils.go 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #418      +/-   ##
==========================================
- Coverage   34.53%   32.75%   -1.78%     
==========================================
  Files         119      119              
  Lines        9014     8950      -64     
==========================================
- Hits         3113     2932     -181     
- Misses       5503     5597      +94     
- Partials      398      421      +23     
Flag Coverage Δ
e2e 32.75% <52.17%> (-1.78%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@openshift-merge-bot
openshift-merge-bot Bot merged commit 266f250 into openshift:master Oct 29, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants